package com.cakebackoffice.clientsoap;

import com.cakebackoffice.clientsoap.Exception.SoapClientException;
import com.cakebackoffice.clientsoap.Exception.SoapComException;
import org.ksoap2.serialization.SoapPrimitive;

import java.util.Map;

public class StringMethod extends Method<String> {

    public StringMethod(SoapClient soapClient, String methodName, Map<String, Object> parameters) {
        super(soapClient, methodName, parameters);
    }

    @Override
    public String getResult(Class<String> type) throws SoapComException, SoapClientException {
        return getResult();
    }


    public String getResult() throws SoapComException, SoapClientException {
        Object response = executeCall();
        if (response instanceof SoapPrimitive) {
            return response.toString();
        } else {
            throw new SoapClientException();
        }
    }
}

